### takes model and observed, calculates likelihood

## study time per period
## returns NA for missing
likelihood_s<-function(s_obs, s_model) 
	{
  # constrains s_obs to be positive
  if (is.na(s_obs)==1 | is.na(s_model)==1) 
  {
    NA
  } else {
    if (s_obs==s_lb) ## vestigial case, allowing for tobit-type specification
      {
      max(pnorm(s_lb  - s_model, mean=0, sd=sigma_eta), lowest_prob)
      }   else {
      max(dnorm(s_obs - s_model, mean=0, sd=sigma_eta), lowest_prob) 
      }
	}
}

## gpa per semester
## returns NA for missing
## censored at 0 and 4
likelihood_y<-function(y_obs, y_model) 
{
  if (is.na(y_obs)==1 | is.na(y_model)==1) 
  {
    NA
  } else {        ## not missing either y_obs or y_model
    if (y_obs==y_lb) ## vestigial case, allowing for tobit-type specification
    {
      max(pnorm(y_lb - y_model, mean=0, sd=sigma_eps), lowest_prob)
    } 
    else {
      if (y_obs==y_ub) {
        max(1 - pnorm(y_ub-y_model, mean=0, sd=sigma_eps), lowest_prob)
      } else{
        max(dnorm(y_obs - y_model, mean=0, sd=sigma_eps), lowest_prob) 
      }
    }
  }
}
